package cn.getech.data.development.utils.oozie;

import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;


public class SubWorkFlowUtil {

    /***
     * 待开发  根据节点的连线生成对应的工作流引用工作流
     * @return
     */
    public static String creatSubworkflowXml() {
        try {
            Document document = DocumentHelper.createDocument();
            Element workflowApp = document.addElement("workflow-app");
            workflowApp.addAttribute("name", "swf-${subworkflowId}")
                    .addNamespace("xmlns", "uri:oozie:workflow:1.0");

            Element action = workflowApp.addElement("action");
            Element workflow = action.addElement("workflow");
            Element appPath = workflow.addElement("app-path");
            appPath.setText("${workflowAppUri}");
            Element configuration = workflow.addElement("configuration");
            Element property = configuration.addElement("property");
            property.addElement("name").setText("jobTracker");
            property.addElement("value").setText("${jobTracker}");
            Element property2 = configuration.addElement("property");
            property2.addElement("name").setText("nameNode");
            property2.addElement("value").setText("${nameNode}");
            Element property3 = configuration.addElement("property");
            property3.addElement("name").setText("queueName");
            property3.addElement("value").setText("${queueName}");

            return document.asXML();
        } catch (Exception e) {

        }
        return "";
    }
}
